import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  server: {
    host: "0.0.0.0",
    proxy: {
      // 代理配置
      "/api": {
        target: "https://api.coze.cn", // 目标后端服务地址
        secure: false,
        changeOrigin: true, // 必须设置为true
        rewrite: (path) => path.replace(/^\/api/, ""), // 重写请求路径，去掉/api
      },
    },
  },
});
